﻿#region License

// Droid Manager - An Android Phone Tools Suite
// Copyright (C) 2011
// 
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#endregion

using System.Windows.Forms;
using DroidManager.Data;

namespace DroidManager.UI
{
    /// <summary>
    /// Main settings form
    /// </summary>
    internal partial class MainSettings : Form
    {
        /// <summary>
        /// Form Istance holder
        /// </summary>
        private static MainSettings _msi;

        /// <summary>
        /// Form Constructor
        /// </summary>
        internal MainSettings()
        {
            InitializeComponent();
            _msi = this;
        }

        /// <summary>
        /// Get form instance
        /// </summary>
        /// <returns></returns>
        internal static MainSettings GetInstance()
        {
            return _msi;
        }

        #region Form Controls Methods

        private void closeBtn_Click(object sender, System.EventArgs e)
        {
            this.Close();
        }

        private void MainSettings_Load(object sender, System.EventArgs e)
        {
            adbPathTxt.Text = GlobalVars.AdbFilePath;
            aaptPathTxt.Text = GlobalVars.AaptFilePath;
        }

        private void saveBtn_Click(object sender, System.EventArgs e)
        {
            GlobalVars.AdbFilePath = adbPathTxt.Text;
            GlobalVars.AaptFilePath = aaptPathTxt.Text;
            MessageBox.Show("Saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }

        private void adbBrowseBtn_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "adb.exe|*.exe";
            open.FileName = "adb.exe";
            open.CheckFileExists = true;
            if (open.ShowDialog() == DialogResult.OK)
            {
                adbPathTxt.Text = open.FileName;
            }
        }

        private void aaptBrowseBtn_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "aapt.exe|*.exe";
            open.FileName = "aapt.exe";
            open.CheckFileExists = true;
            if (open.ShowDialog() == DialogResult.OK)
            {
                adbPathTxt.Text = open.FileName;
            }
        }

        #endregion
    }
}